package thread1;

import java.util.concurrent.*;

public class futureDemo1 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(5, 5, 20, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
        ExecutorService executorService = Executors.newFixedThreadPool(1);

        Future<String> submit = poolExecutor.submit(() -> {
            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            ;
            return "hello";

        });
        String s = submit.get();
        System.out.println(s);
        poolExecutor.shutdown();
    }
}
